﻿using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace PesticideManage.Domain.AggregatesModel.BatchQRCodeAggregate;
public class QRCodeDTO
{
    /// <summary>
    /// 第9~11位,产品规格码/批次,企业自行编制
    /// </summary>
    [Range(1, 999)]
    public int ProductSpecificationCode { get; set; }
    public int Count { get; set; }
    /// <summary>
    /// 前台网址，二维码展示网址
    /// </summary>
    public string? Host { get; set; }

    public int PesticideId { get; set; }
}
public class QRCodeNumerDTO
{
    /// <summary>
    /// 第1位农药登记类别代码
    /// 1. PD 2. WP 3. 临时登记
    /// </summary>
    [JsonIgnore]
    public int PesticideRegistrationType { get; set; }
    /// <summary>
    /// 第2~7位,农药登记证后六位数字
    /// </summary>
    [JsonIgnore]
    public string? LastSixDigitsOfRegistration { get; set; }
    /// <summary>
    /// 第8位,生产类型
    /// 1. 农药登记证持有人生产
    /// 2. 委托加工
    /// 3. 委托分装
    /// </summary>
    [JsonIgnore]
    public int ProductionType { get; set; }
    /// <summary>
    /// 第9~11位,产品规格码,企业自行编制
    /// </summary>
    [Range(1, 999)]
    public int ProductSpecificationCode { get; set; }

    public override string ToString() => @$"{PesticideRegistrationType}{LastSixDigitsOfRegistration!.PadLeft(6, '0')}{ProductionType}{ProductSpecificationCode.ToString().PadLeft(3, '0')}";
    //[StringLength(10)]
    //public string? GoodsName { get; set; }

    public int Count { get; set; }
    /// <summary>
    /// 前台网址，二维码展示网址
    /// </summary>
    public string? Host { get; set; }
    [JsonIgnore]
    public string FileName { get; set; } = string.Empty;
    public int PesticideId { get; set; }
}